using System;
using System.Collections.Generic;
using System.Text;
using Utils;
using Utils.WebFramework;
using System.Drawing;
using System.Drawing.Imaging;
using Utils.Model;
namespace Controllers
{
    class Utils
    {
        public ActionResult Error(Httper httper, HttpObject httpObject, Resource resource)
        {
            ViewResult result = new ViewResult();

            Holder<string> errorModel = new Holder<string>();

            Exception ex = Framework.GetFramework().Error;
            if ( ex != null )
            {
                errorModel["trace"] = ex.StackTrace;

                while (ex != null)
                {
                    errorModel.AddBack(ex.Message);
                    ex = ex.InnerException;
                }
            }

            Element vars = new Element();
            errorModel["vars"] = vars;

            foreach (string name in httper.Names)
            {
                if (!name.StartsWith("__"))
                {
                    vars[name] = httper[name];
                }
            }

            result["errorModel"] = errorModel;

            return result;
        }
        
    }
}
